﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Configuration;

namespace AnaGiftedProject
{
    public partial class WebForm10 : Page
    {
      
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            using(DatabaseGiftedEntities ctx=new DatabaseGiftedEntities())
            {
                string imagefolder = "PersImages";
                string savepath;
                string savefile;
                PersonalImg pimg = new PersonalImg();
               if (FileUpload1.PostedFile != null)
                {
                    savepath = Path.Combine(Request.PhysicalApplicationPath, imagefolder);
                    savefile = Path.Combine(savepath, FileUpload1.FileName);
                    FileUpload1.SaveAs(savefile);
                    pimg.UserId = 1;
                    pimg.PersImgName = txtName.Text;
                    pimg.PersImgDescription = txtDes.Text;
                    pimg.PersImgTrack = savepath;
                }
                    ctx.AddToPersonalImgs(pimg);
                    ctx.SaveChanges();
                    DLPersImg.DataBind();
           }   
        }
   }
}
